import numpy as np
import yaml
class Loader(object):
    @staticmethod
    def load_dict(path):
        print("loading...", path)
        return np.load(path, allow_pickle=True).item()
    @staticmethod
    def load_yaml(path):
        print("loading...", path)
        file = open(path, 'r', encoding="utf-8")
        file_data = file.read()
        config = yaml.load(file_data, Loader=yaml.FullLoader)
        device = str(config.get('Train').get('device'))
        config['Train']['device'] = "cuda:" + device if device.upper() != 'CPU' else 'cpu'
        file.close()
        return config
